import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Main',
    component: () => import('../views/Main.vue'),
    children: [
      {
        path: '/bookshelf',
        name: 'Bookshelf',
        component: () => import('../views/Bookshelf.vue')
      },
      {
        alias: '',
        path: '/bookCity',
        name: 'BookCity',
        component: () => import('../views/BookCity.vue')
      },
      {
        path: '/find',
        name: 'Find',
        component: () => import('../views/Find.vue')
      },
      // {
      //   path: '/user',
      //   name: 'User',
      //   component: () => import('../views/User.vue')
      // },
      {
        path: '/class',
        name: 'Class',
        component: () => import('../views/Class.vue')
      }
    ]
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('../views/Search.vue')
  },
  {
    path: '/searchList',
    name: 'SearchList',
    component: () => import('../views/SearchList.vue')
  },
  {
    path: '/bookDetails',
    name: 'BookDetails',
    component: () => import('../views/BookDetails.vue')
  },
  {
    path: '/catalogue',
    name: 'Catalogue',
    component: () => import('../views/Catalogue.vue')
  },
  {
    path: '/read',
    name: 'Read',
    component: () => import('../views/Read.vue')
  },
  {
    path: '/booklistDetails',
    name: 'BooklistDetails',
    component: () => import('../views/BooklistDetails.vue')
  }
]

const router = new VueRouter({
  routes
})

// // 解决路由跳转同一导航报错问题
// const VueRouterPush = VueRouter.prototype.push
//  VueRouter.prototype.push = function push (to) {
//   return VueRouterPush.call(this, to).catch(err => err)
// }

export default router
